require( '$d/css/common.less' );
require('./style.less');
define( [
  'jquery',
  'require',
  'header',
  'message',
  'artCategoryHandle',
  'api',
  'pagination',
  'combiner',
  'bootstrap',
  'bigwe_utils',
  'constants',
  'behavior',
  'searchMaterial'
], function( $, require ) {
  var bu = require( 'bigwe_utils' );
  var ShowTitleMessage = require( 'message' ),
    showTime = ShowTitleMessage.showTime,
    BIGWE_API = require( 'api' ),
    thisApis = BIGWE_API.SEARCH,
    escapeHtml = bu.escapeHtml,
    getUrlParam = bu.getUrlParam;
  var category = require( 'artCategoryHandle' ).category,
    category_color = require( 'artCategoryHandle' ).category_color;

  var searchMaterial = require( 'searchMaterial' );

  var c = require( 'constants' );
  var behavior = require( 'behavior' );

  //点击到相应的页面
  searchMaterial.addClassByIndex( 1 );
  $( '.selectpicker' ).selectpicker( 'refresh' );
  $( '.fenlei_cate .choice' ).on( 'mouseenter', 'span', function( e ) {
    $( '.fenlei_more' ).fadeIn();
    e.stopPropagation();
  } );
  $( '.laiyuan_cate .choice' ).on( 'mouseenter', 'span', function( e ) {
    $( '.laiyuan_more' ).fadeIn();
    e.stopPropagation();
  } );
  $( '.fenlei_more,.laiyuan_more' ).mouseleave( function() {
    $( this ).fadeOut();
  } );

  //分类过滤
  // Sherlockl SEO优化  已同步渲染到页面
  /*var category_html = '';
  var search_cate = $.extend( {}, category );
  for ( var i in search_cate ) {
  	category_html += '<a href="' + seo.U('/search/articles?cc=' + i) + '" class="filter_item" _value="' + i + '">' + search_cate[ i ] + '</a>'
  }
  $( '.fenlei_more' ).empty().append( '<a class="filter_item" _value="">全部</a>' + category_html );*/
  var search_type = 'art',
    search_key = $( '#hiddenData' ).data( 'search_key' ),
    isOk = true,
    isHotOk = true;
  search_key = search_key || '';
  if ( search_key != '' ) {
    var state = {
      search_type: search_type,
      search_key: search_key,
    };
    history.replaceState( state, document.title, '/search/articles?search_key=' + search_key + '' );
  }
  //隐藏判断
  if ( search_key == '' ) {
    $( '.from_nav_1' ).removeClass( 'hide' );
  } else {
    $( '.from_nav_0' ).removeClass( 'hide' );
  }

  //栏目切换
  $( '.bw-columns' ).bwColumns( [ '全部', '10W+' ], function( index ) {
    var idx = index.index();
    var resetOption;
    $( this ).data( 'idx', idx );
    $( '.article_container>div' ).eq( idx ).fadeIn().siblings().hide();
    if ( idx == 0 ) {
      resetOption = _search.options;
      $( '.laiyuan_cate' ).removeClass( 'hide' );
      $( '.search_filter' ).slideDown();
      //$( '.add_gather' ).show();
      $( '.search_main .upper .article_sort' ).show();
    } else if ( idx == 1 ) {
      resetOption = _search.hotOptions;
      $( '.laiyuan_cate' ).addClass( 'hide' );
      $( '.search_filter' ).slideUp();
      //$( '.add_gather' ).hide();
      $( '.search_main .upper .article_sort' ).hide();
    }
    _search.resetFilter( resetOption );

  } ).data( 'idx', 0 );

  //搜索接口
  var _search = {
    options: {
      key: decodeURI( search_key ),
      type: search_type,
      p: 1,
      l: 10,
      // time: 'week',
      // order: 'score'
    },
    hotOptions: {
      key: decodeURI( search_key ),
      cc: '',
      // 是否原创
      cs: '',
      // 默认month；一周内：week；一个月内：month；三个月内：quarter；一年内：year
      time: 'week',
      p: 1,
      l: 10
    },
    doSearch: function( options ) {
      var idx = $( '.bw-columns' ).data( 'idx' );
      ShowTitleMessage.show( '正在加载' );
      if ( idx == 0 ) {
        this.doArtSearch( options ).then( function() {
          ShowTitleMessage.hide()
        } );
      } else if ( idx == 1 ) {
        this.doHotSearch( options ).then( function() {
          ShowTitleMessage.hide()
        } );
      }

      return this;
    },
    doHotSearch: function( options ) {
      $.extend( this.hotOptions, options );
      isHotOk = true;
      return this.hotArtList();

    },
    doArtSearch: function( options ) {
      $.extend( this.options, options );
      isOk = true;
      return this.result_list();
    },
    init: function() {
      //ShowTitleMessage.show( '正在加载' );
      //$.when( this.result_list(), this.hotArtList() ).then( ShowTitleMessage.hide );
      // -================静态化后需要加载的东西
      var total_rows_hot = $( '#total_rows_hot' ).val() * 1;
      var total_rows = $( '#total_rows' ).val() * 1;
      total_rows_hot && this.hotPaging( total_rows_hot > 500 ? 500 : total_rows_hot );
      total_rows && this.paging( total_rows > 500 ? 500 : total_rows );
      $( '.article_container [data-toggle="tooltip"]' ).tooltip();

      this._sort();
      this.other_search();
      this._filter();
      this.result_list();
    },
    result_list: function( _parameter ) {
      var html_list = '',
        source_icon = '',
        _time = null,
        _this = this;

      return $.ajax( {
        type: "post",
        dataType: "json",
        url: BIGWE_API.SEARCH.SEARCH_LIST,
        data: this.options,
        success: function( data ) {
          if ( data.ret == 0 ) {
            var _parameter = data.data.data.articles;
            var totalNumber = data.data.total_rows;
            if ( isOk == true ) {
              $( '#article_paging' ).hide();
            }
            //文章列表
            for ( var i in _parameter ) {
              html_list += _this.buildArtHtml( _parameter[ i ], data.data.data.words );
            }

            if ( _this.isSycnz ) {
              $( '.normal_art .article_list' ).empty().append( _parameter.length == 0 ? '<p class="no_content"><span class="glyphicon glyphicon-flash"></span>暂无内容</p>' : html_list );
            }
            _this.isSycnz = true;
            $( '[data-toggle="tooltip"]' ).tooltip( {
              trigger: 'hover'
            } );

            $( '.search_main .upper .green' ).text( totalNumber )
            if ( isOk == true && totalNumber > 10 ) {
              totalNumber > 500 ? totalNumber = 500 : totalNumber;
              _this.paging( totalNumber );
            }
            //大家还在搜
            var hot_html = '';
            var hot_words = data.data.data.hot_words;
            for ( var i in hot_words ) {
              hot_html += '<li class="clearfix">' +
                '<span class="fl">' + ( Number( i ) + 1 ) + '</span>' +
                '<a class="fl" href="javascript:;">' + hot_words[ i ].hot_words + '</a>' +
                '<div class="progress_bar fl"><span title="热度" style="width:' + hot_words[ i ].heat + '%;"></span></div>' +
                '</li>'
            }
            $( '.search_list ul' ).empty().append( hot_html );
          } else {
            ShowTitleMessage.showWarning( '请输入搜索内容', showTime );
          }
        }
      } );
    },
    // 10W+文章获取
    hotArtList: function() {
      var _this = this;

      return $.ajax( {
        url: thisApis.GET_HOT_ART,
        data: this.hotOptions,
        type: 'post',
        success: function( data ) {

          data = typeof data === 'string' ? $.parseJSON( data ) : data;

          var html_list = '';

          if ( isHotOk == true ) {
            $( '#hot_paging' ).hide();
          }
          if ( data.ret == 0 ) {
            var _parameter = data.data.arts;
            var totalNumber = data.data.total_rows;
            if ( _parameter.length == 0 ) {
              $( '.hot_art .article_list' ).empty().append( '<p class="no_content"><span class="glyphicon glyphicon-flash"></span>暂无内容</p>' );
            } else {
              //文章列表
              for ( var i in _parameter ) {
                html_list += _this.buildArtHtml( _parameter[ i ], data.data.words );
              }
              $( '.hot_art .article_list' ).empty().append( html_list );
              if ( isHotOk && totalNumber > 10 ) {
                totalNumber = totalNumber > 500 ? 500 : totalNumber;
                _this.hotPaging( totalNumber );
              }
            }
          }

        }
      } );
    },
    buildArtHtml: function( article, words ) {
      var rtHtml = '';

      var publisher_html = '';
      //www.cbdio.com封面图特殊处理
      if ( article.cover_img_url == 'http://www.cbdio.com/' ) {
        article.cover_img_url = 'http://www.cbdio.com/assets/i/no_picture.jpg';
      }
      var img_src = ( article.cover_img_url != '' ) ? ( article.source == 'www.cpanet.cn' ? article.cover_img_url : c.surpportHostName + '/timthumb.php?w=130&src=' + article.cover_img_url ) : ( c.resPath + '/images/wuyulantu.png' );
      //判断平台icon   
      if ( article.source == 'bigwe.com' ) {
        source_icon = 'icon-iconbigwe';
      } else if ( article.source == 'toutiao.com' ) {
        source_icon = 'icon-icontoutiao';
      } else if ( article.source == 'mp.weixin.qq.com' ) {
        source_icon = 'icon-weixin';
      } else if ( article.source == 'news.163.com' ) {
        source_icon = 'icon-wangyi';
      } else if ( article.source == 'ifeng.com' ) {
        source_icon = 'icon-ifeng';
      } else if ( article.source == 'news.sina.com.cn' ) {
        source_icon = 'icon-xinlang';
      } else {
        source_icon = 'noicon';
      }
      //判断发布平台
      // else if(_parameter[i].source == 'toutiao.com'){
      //     publisher_html += '<div class="btn_plat" onclick="window.open(\'/profile?biz=' + getUrlParam('__biz', _parameter[i].source_url) + '&gn=' + escape(_parameter[i].publisher) + '&platform=toutiao.com\')"><span class="iconfont '+source_icon+'"></span>' +
      //     '<span class="article-account">' + _parameter[i].publisher + '</span></div>';
      // }头条账号链接
      if ( article.source == 'mp.weixin.qq.com' ) {
        publisher_html += '<a class="btn_plat" href="/profile?biz=' + getUrlParam( article.source_url, '__biz' ) + '&platform=mp.weixin.qq.com" target="_blank"><span class="iconfont ' + source_icon + '"></span>' +
          '<span class="article-account">' + article.publisher + '</span></a>';
      } else if ( article.source == 'bigwe.com' ) {
        publisher_html += '<a class="btn_plat" href="/profile?biz=' + escape( article.publisher ) + '&platform=bigwe.com" target="_blank"><span class="iconfont ' + source_icon + '"></span>' +
          '<span class="article-account">' + article.publisher + '</span></a>';
      } else {
        publisher_html += '<span class="iconfont platform-icon ' + source_icon + '"></span>' +
          '<span class="article-account ' + ( !article.publisher || article.publisher == ' ' ? 'hide' : '' ) + '">' + article.publisher + '</span>';
      }
      var yuanc = Number( article.copyright_stat ); //原创标识
      var copyright_img = '';
      if ( yuanc == 1 || yuanc == 2 ) {
        if ( article.source == 'toutiao.com' ) {
          copyright_img = '<span class="toutiao_copyright">原创</span>';
        } else if ( article.source == 'bigwe.com' ) {
          copyright_img = '<img src="' + c.resPath + '/images/original1.png" alt="" class="original"/>';
        } else {
          copyright_img = '<img src="' + c.resPath + '/images/original2.png" alt="" class="original"/>';
        }
      }
      //时间
      _time = new Date( article.publish_time_millis ).format( 'yyyy-MM-dd hh:mm' );
      var _title = article.title;
      // var _content = escapeHtml( article.summary );
      var _content = "";
      if ( article.summary ) {
        _content = article.summary;
      }

      var participle = words || [];
      // 没有code取其他
      article.category_code || ( article.category_code = '000' );
      //高亮
      // if ( participle.length == 0 ) {
      // 	search_wz = $( '.search_ipt' ).val();
      // 	if ( search_wz != '' ) {

      // 		var regStr = new RegExp( bu.regExpReplace( search_wz ), "g" )
      // 		_title = _title.replace( regStr, '<em class="green">' + search_wz + '</em>' );
      // 		_content = _content.replace( regStr, '<em class="green">' + search_wz + '</em>' );
      // 	}
      // } else {
      // 	for ( var j in participle ) {
      // 		var regexp = new RegExp( bu.regExpReplace( participle[ j ] ), "g" )
      // 		_title = _title.replace( regexp, '<em class="green">' + participle[ j ] + '</em>' );
      // 		_content = _content.replace( regexp, '<em class="green">' + participle[ j ] + '</em>' );
      // 	}
      // }

      rtHtml += '<li class="article-sub">' +
        '<div class="article-title">' +
        '<span class="hide" style="background:' + category_color[ article.category_code || '000' ] + '">' + category[ article.category_code || '000' ] + '</span>' +
        '<a data-cnzz-trackevent="' + ( article.art_type == 'normal' ? behavior.allArt : behavior._10WPlus ) + behavior.clickstr + c.userLoginBehavior + '" href="/article?p=' + article.cd + '&cc=' + article.category_code + '&s=search_art' + '" target="_blank">' + _title + '</a>' +
        '</div>';

      // 有背景图 或者来自微信或者来自微知
      if ( article.cover_img_url && article.cover_img_url.length || article.source == 'bigwe.com' || article.source == 'mp.weixin.qq.com' ) {
        rtHtml += '<div class="picture"><a data-cnzz-trackevent="' + ( article.art_type == 'normal' ? behavior.allArt : behavior._10WPlus ) + behavior.clickstr + c.userLoginBehavior + '" href="/article?p=' + article.cd + '&cc=' + article.category_code + '" target="_blank" style="background-image: url(' + img_src + ')"></a>' + copyright_img + '</div>'
      }

      rtHtml += '<div class="article-sub-taxt" data-articleid="' + article.cd + '" data-title="' + article.title + '" data-img="' + article.cover_img_url + '" data-url="/article?p=' + article.cd + '" data-id="' + article.cd + '" style="margin-left:0">' +
        '<p>' + _content + '</p>' + publisher_html +
        '<span class="article-time">' + _time + '</span>' +
        '<span class="iconfont icon-collect article-collect" data-toggle="tooltip" title="" data-original-title="收藏"></span>' +
        '<span class="iconfont icon-box article-merge" addcar-event="" data-toggle="tooltip" title="" data-original-title="加入合成器"></span>' +
        '</div>' +
        '</li>'

      return rtHtml;
    },
    _sort: function() {
      //按条件排序
      var _this = this;
      $( '.search_main .upper select' ).change( function() {
        _this.options.order = $( this ).val();
        _this.result_list();
      } );

    },
    _filter: function() {
      var _this = this;
      // 分类
      $( '.fenlei_more' ).on( 'click', '.filter_item', function( e ) {
        e.preventDefault();
        $( '.fenlei_cate .choice span' ).text( this.innerText );
        _this.doSearch( {
          cc: $( this ).attr( '_value' ),
          p: 1
        } );

        params_rank.data[ 'ca' ] = $( this ).attr( '_value' );
        params_rank.data[ 'p' ] = 1;
        myAjax( params_rank );
        $( this ).parent().fadeOut();
      } );

      // 来源
      $( '.laiyuan_more' ).on( 'click', '.filter_item', function( e ) {
        e.preventDefault();
        $( '.laiyuan_cate .choice span' ).text( this.innerText );

        _this.doSearch( {
          sc: $( this ).attr( '_value' ),
          p: 1
        } );

        params_rank.data[ 'sc' ] = $( this ).attr( '_value' );
        params_rank.data[ 'p' ] = 1;
        //没有原创的平台
        if ( $( this ).attr( '_value' ) == 'news.163.com' || $( this ).attr( '_value' ) == 'ifeng.com' || $( this ).attr( '_value' ) == 'news.sina.com.cn' ) {
          $( '.leixing_cate .choice span:first-child' ).addClass( 'green' ).siblings().removeClass( 'green' );
          $( '.leixing_cate .choice span:gt(0)' ).hide();
          _this.options.cs = '';
        } else {
          $( '.leixing_cate .choice span' ).show();
        }
        myAjax( params_rank );
        $( this ).parent().fadeOut();
      } );

      // 类型
      $( '.leixing_cate' ).on( 'click', '.filter_item', function( e ) {
        e.preventDefault();
        $( this ).addClass( 'green' ).siblings().removeClass( 'green' );
        _this.doSearch( {
          cs: $( this ).attr( '_value' ),
          p: 1
        } );

        params_rank.data[ 'cr' ] = $( this ).attr( '_value' );
        params_rank.data[ 'p' ] = 1;
        myAjax( params_rank );
      } );
      // 按时间
      $( '.shijian_cate' ).on( 'click', '.filter_item', function( e ) {
        e.preventDefault();
        $( this ).addClass( 'green' ).siblings().removeClass( 'green' );
        _this.doSearch( {
          time: $( this ).attr( '_value' ),
          p: 1
        } );

      } );
    },
    other_search: function() {
      //无刷新替地址
      var _this = this;

      $( '.search_list' ).on( 'click', ' a.fl', function() {
        /*$( '.home_search_ipt .search_ipt' ).val( $( this ).text() )
        $( '.home_search_ipt button' ).click();*/
        searchMaterial.setInputVal( $( this ).text() );
      } );
      /*$( '.home_search_ipt button' ).click( function( e ) {


      } );*/
      searchMaterial.onSearch = function( search_key_in ) {
        search_type = 'art';
        search_key = search_key_in;
        if ( search_key != '' ) {
          var searchParam = {
            key: search_key,
            type: search_type,
            p: 1
          };

          ShowTitleMessage.show( '正在加载' );
          $.when( _search.doArtSearch( searchParam ), _search.doHotSearch( searchParam ) ).then( ShowTitleMessage.hide );

          //隐藏判断
          $( '.from_nav_1' ).addClass( 'hide' );
          $( '.from_nav_0' ).removeClass( 'hide' );
          var state = {
            search_type: search_type,
            search_key: search_key,
          };
          // sherlockl 运营数据统计
          behavior.addRecord( {
            category: behavior.searchArt,
            action: search_key
          } );
          window.history.replaceState( state, document.title, '/search/articles?search_key=' + search_key + '' );
        }
      }

      /* $( '.home_search_ipt .search_ipt' ).bind( 'keypress', function( event ) {
        search_type = $( '.header_container_main .search_area .search_item.selected' ).attr( 'kw' );
        search_key = $( '.home_search_ipt .search_ipt' ).val();
        if ( event.keyCode == "13" ) {
          if ( $( '.search_ipt' ).val() != '' ) {
            event.stopImmediatePropagation();
            event.preventDefault();
            $( '.home_search_ipt button' ).trigger( 'click' );
          }
        }
      } ); */
      searchMaterial.setInputVal( decodeURI( search_key ), true );
      //$( '.home_search_ipt .search_ipt' ).val( decodeURI( search_key ) );
      $( '.fenlei_cate .choice>span' ).text( category[ $( '#hiddenData' ).data( 'cc' ) ] );
      window.addEventListener( 'popstate', function( e ) {
        if ( history.state ) {
          var state = e.state;
          _this.options.key = state.search_key;
          _this.options.type = state.search_type
          _this.options.p = 1;
          isOk = true;
          _this.result_list();
          searchMaterial.setInputVal( decodeURI( state.search_key ), true );
        } else {
          window.location.reload();
        }
      }, false );

    },
    paging: function( _parameter ) {
      var _this = this;
      $( "#article_paging" ).pagination( _parameter, {
        num_edge_entries: 1,
        num_display_entries: 8,
        items_per_page: 10,
        link_to: 'javascript:window.scrollTo(0,0);',
        prev_text: '上一页',
        next_text: '下一页',
        callback: function( _index, jq ) {
          if ( isOk == true ) {
            isOk = false;
            return;
          } else {
            _this.options.p = _index + 1;
            _this.result_list();
          }
        }
      } );
      $( '#article_paging' ).show();
    },
    hotPaging: function( totalCount ) {
      var _this = this;
      $( "#hot_paging" ).pagination( totalCount, {
        num_edge_entries: 1,
        num_display_entries: 8,
        items_per_page: 10,
        link_to: 'javascript:window.scrollTo(0,0);',
        prev_text: '上一页',
        next_text: '下一页',
        callback: function( _index, jq ) {
          if ( isHotOk == true ) {
            isHotOk = false;
            return;
          } else {
            _this.hotOptions.p = _index + 1;
            _this.hotArtList();
          }
        }
      } );
      $( '#hot_paging' ).show();
    },
    resetFilter: function( options ) {
      var $fitler = $( '.article_right .filter' );
      $( '.fenlei_cate .choice>span', $fitler ).text( category[ options.cc ] || '全部' );
      $( '.laiyuan_cate .choice>span', $fitler ).text( $( '.laiyuan_more [_value="' + ( options.sc || '' ) + '"]' ).text() )
      $( '.leixing_cate .choice [_value="' + ( options.cs || '' ) + '"]', $fitler ).addClass( 'green' ).siblings().removeClass( 'green' );
      $( '.shijian_cate .choice [_value="' + ( options.time || '' ) + '"]' ).addClass( 'green' ).siblings().removeClass( 'green' );

      return this;
    }
  }
  _search.init();
  $.extend( _search.options, $( '#hiddenData' ).data() );

  /*文章收藏点击*/
  $( ".article_list" ).on( "click", ".article-collect", function() {
    var re = $( this );
    var articleID = $( this ).parent().attr( 'data-articleID' );

    if ( re.hasClass( "golden" ) ) {
      $.ajax( {
        type: 'post',
        url: '/favorites/del',
        data: {
          id: articleID,
          rt: 'collectArt',
        },
        success: function( data ) {
          var json = typeof data === 'string' ? $.parseJSON( data ) : data;
          if ( json.ret == 0 ) {
            ShowTitleMessage.showWarning( '取消收藏成功！', showTime );
            re.removeClass( "golden" );
          }
        }
      } )
    } else {
      $.get( BIGWE_API.COLLECT_ART.GET_COLLECT_ART, {
        cd: articleID,
        rt: "collectArt"
      }, function( data ) {
        var data = $.parseJSON( data )
        if ( data.ret === 0 || data.ret === 70004 ) {
          re.addClass( "golden" );
          ShowTitleMessage.show( '收藏成功！', showTime );
        } else {
          ShowTitleMessage.show( data.msg, 1000 );
        }
      } );
    }
  } );

  /*排行榜*/
  var params_rank = {
    url: BIGWE_API.SEARCH.GET_ART_RANK,
    data: {
      p: 1,
      t: 2,
    },
    callBack: rank_ls
  }

  function rank_ls( json ) {
    var categoryText = {
      '1': behavior.weeklike,
      '2': behavior.weekread
    }

    if ( json.ret != 0 ) {
      $( '.article_right_list' ).hide();
      return;
    } else {
      $( '.article_right_list' ).show();
    }

    var rankings = json.articles;
    var ranking_html = "";

    for ( var key in rankings ) {
      var ranking = rankings[ key ];
      var color_style = ( key == 0 ) ? 'bg-red' : ( key == 1 ) ? 'bg-orange' : ( key == 2 ) ? ' bg-beige' : 'bg-black';
      var icon = ( params_rank.data[ 't' ] == 2 ) ? 'iconfont icon-yuedu' : 'iconfont icon-dianzan';
      ranking_html += '<div>' +
        '<span class="serial-number ' + color_style + '">' + ( key * 1 + 1 ) + '</span>' +
        '<p class="reading-text"><a data-cnzz-trackevent="' + categoryText[ this.data.t ] + behavior.splitStr + '点击阅读' + behavior.splitStr + c.userLoginBehavior + '" href="/article?p=' + ranking.cd + '" target="_blank">' + ranking.title + '</a></p>' +
        '<p class="reading-number"><span class="' + icon + '"></span><span>' + ranking.number + '</span></p>' +
        '</div>'
    }
    $( '.article_right_list' ).find( '.list_show' ).empty().append( ranking_html );
  }

  function myAjax( opt ) {
    //ShowTitleMessage.show('正在加载...');
    $.ajax( {
      type: 'get',
      url: opt[ 'url' ],
      data: opt[ 'data' ],
      success: function( data ) {
        opt[ 'callBack' ]( data );
      },
      error: function( XMLHttpRequest, textStatus, errorThrown ) {
        console.log( textStatus );
        console.log( XMLHttpRequest.status );
        console.log( XMLHttpRequest.readyState );
      },
      // complete: function() {
      //     ShowTitleMessage.hide();
      // }
    } );
  }
  $( '.article_right_list' ).find( ".list_btn" ).click( function() {
    var _left = $( this ).position().left;
    if ( $( this ).hasClass( 'huise' ) ) {
      return;
    }
    $( '.article_right_list' ).find( ".list_btn" ).removeClass( 'huise' );
    $( this ).addClass( "huise" );
    $( '.article_right_list span.underline' ).animate( {
      left: _left,
    } );
    if ( $( this ).index() == 0 ) {
      params_rank.data[ 't' ] = 2
    } else {
      params_rank.data[ 't' ] = 1
    }
    myAjax( params_rank );
  } );
  myAjax( params_rank );
} )